#include "mypushbutton.h"
#include <QPainter>
#include <QPropertyAnimation>

myPushButton::myPushButton(QWidget *parent) : QPushButton(parent)
{

}

void myPushButton::moveDown()
{
    QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry",this);
    animation->setStartValue(this->geometry());
    animation->setEndValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
    animation->setDuration(100);
    animation->start(QAbstractAnimation::DeleteWhenStopped);
}

void myPushButton::moveUp()
{
    QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry",this);
    animation->setStartValue(this->geometry());
    animation->setEndValue(QRect(this->x(),this->y()-10,this->width(),this->height()));
    animation->setDuration(100);
    animation->start(QAbstractAnimation::DeleteWhenStopped);

}

void myPushButton::paintEvent(QPaintEvent *ev)
{
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/res/nav.png");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}
